package com.wenkang.stu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wenkang.stu.pojo.SysMenu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MenuMapper extends BaseMapper<SysMenu> {

    @Select("SELECT DISTINCT p.* FROM sys_user u RIGHT JOIN \n" +
            "sys_user_role ur ON u.id = ur.user_id RIGHT JOIN\n" +
            "sys_role r ON ur.role_id = r.id RIGHT JOIN\n" +
            "sys_role_menu rp ON r.id = rp.role_id RIGHT JOIN\n" +
            "sys_menu p ON rp.menu_id = p.id\n" +
            "WHERE u.id = #{id}")
    List<SysMenu> selectMenusByUserId(@Param("id") String id);


    List<SysMenu> selectMenusWithRole();

    List<SysMenu> selectAllMenus();
}
